import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2023-11-02
 * Time: 21:01
 */
public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
            }
            int min = arr[0];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                min = Math.min(min, arr[i]);
                sum += arr[i];
            }
            boolean[] dp = new boolean[sum + 1];
            dp[0] = true;
            for (int i = 0; i < n; i++) {
                // 注意这里面必须是倒着来的, 不能是正着
                // 因为正着的话会连续 + 一个值, 这样会加到很多其实不能加到的值
                for (int j = sum; j >= arr[i]; j--) {
                    dp[j] = dp[j] || dp[j - arr[i]];
                }
            }
            int res = sum + 1;
            for (int j = min; j <= sum; j++) {
                if (!dp[j]) {
                    res = j;
                    break;
                }
            }
            System.out.println(res);
        }
    }
}
